/**
 * related to feedback.ui
 * 
 * @Author : 2037630@163.com
 * @Timestamp : 2017-04-19
 */
var notify = sm("do_Notification");
var Controller = require("core/controller");
var constant = require('config/constant');
var log = require("util/log")
var navigate = require("util/navigate")
var router = require("config/router")
var net = require('util/net')
var server = require('config/server')
var user=require('module/userModule')
var feedbackContent=ui("feedbackContent");
log.info("start")
log.info(feedbackContent)
Controller({
	config:{
		name : "feedback",
		header:{
			title:"我要反馈",
			right:{
				text:"保存",
				handle:function(){
					this.sendFeedback()
				}
			}
		}
	},
	data:{
		name:"",
		content:""
	},
	event:{
		"feedbackContent":{
			"textChanged":function(){
				log.info("11111")
				log.info(feedbackContent.text)
				this.data.content=feedbackContent.text
				log.info("3333")
				log.info(this.data.content)
			}
		}
	},
	methods:{
		sendFeedback:function(){
			if(this.data.content==""){ 
				notify.toast("请输入反馈信息!")
				return
			}
			net.send({
				server : server.organization.feedback,
				data:{
					"feedbackDescription": this.data.content,
					"feedbackName": this.data.name
				},
				success : function(data) {
//					绑定用户数据并更新
					notify.toast("提交成功")
					navigate.back()
					
				},
				error : function(data) {
					notify.toast("error")
				},
				scope:this
			})
		}
	},
	loaded: function(){
//		 获取用户信息
		var userName=user.data.userName;
		log.info(userName);
		this.data.name=userName;
		log.info(this.data.name);
	}
	
})